<template>
  <div id="app">
    <!-- <MyProduct title="大刀肉" money="120" :info="msg" />
    <MyProduct title="人肉" money="1200" :info="msg1" /> -->
    <MyProduct
      v-for="(item, index) in list"
      :key="index"
      :title="item.proname"
      :money="item.proprice"
      :info="msg1"
      :id="item.id"
      @kan="kanFn"
    />
  </div>
</template>

<script>
import MyProduct from "./components/my-product.vue";
export default {
  components: {
    MyProduct,
  },
  data() {
    return {
      msg: "辣辣",
      // msg1: "一般般",
      list: [
        { id: 1, proname: "超级好吃的棒棒糖", proprice: 18.8 },
        { id: 2, proname: "超级好吃的大鸡腿", proprice: 34.2 },
        { id: 3, proname: "超级无敌的冰激凌", proprice: 174.2 },
        { id: 4, proname: "超级无敌的牛肉", proprice: 12.2 },
        { id: 5, proname: "超级无敌的马肉", proprice: 140.2 },
        { id: 6, proname: "超级无敌的鸭肉", proprice: 154.2 },
        { id: 7, proname: "超级无敌的鹅肉", proprice: 194.2 },
      ],
    };
  },
  methods: {
    kanFn(id) {
      // console.log(money);
      // console.log(id);
      const randoms = +(Math.random() * 10).toFixed(1);
      // console.log(randoms)
      
      this.list.find((item) => item.id === id).proprice-randoms>0?this.list.find((item) => item.id === id).proprice -= randoms:this.list.find((item) => item.id === id).proprice
    },
  },
};
</script>

<style>
#app {
  display: flex;
  flex-wrap: wrap;
}
</style>
